//
//  ReportFooter.swift
//  ANOA
//
//  Created by zwb on 2016/11/16.
//  Copyright © 2025 aowang. All rights reserved.
//

import UIKit

class ReportFooter: UITableViewHeaderFooterView {

    fileprivate var btn: UIButton!
    var title = "查询"
    var footerAction: (() -> Void)?

    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)

        contentView.backgroundColor = UIColor.white

        btn = UIButton()
        btn.backgroundColor = Theme.primaryColor()
        btn.layer.cornerRadius = 5
        btn.setTitle(title, for: UIControl.State())
        btn.addTarget(self, action: #selector(clickBtn), for: .touchUpInside)
        addSubview(btn)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()

        btn.setTitle(title, for: UIControl.State())
        btn.frame = CGRect(x: 8, y: 8, width: KSGlobal.screenW - 16, height: frame.height - 16)
    }

    @objc fileprivate func clickBtn() {

        if let footerAction = self.footerAction {
            footerAction()
        }
    }
}
